import { IPSDEBindParamLogic } from './ipsdebind-param-logic';
import { IPSDELogic } from './ipsdelogic';
import { IPSDELogicParam } from './ipsdelogic-param';
import { PSDELogicNodeImpl } from './psdelogic-node-impl';

export class PSDEBindParamLogicImpl extends PSDELogicNodeImpl implements IPSDEBindParamLogic {
  protected dstpsdelogicparam: IPSDELogicParam | null = null;

  getDstPSDELogicParam(): IPSDELogicParam | null {
    if (this.dstpsdelogicparam != null) return this.dstpsdelogicparam;
    const value = this.M.getDstPSDELogicParam;
    if (value == null) {
      return null;
    }
    const ipsdelogic = this.getParentPSModelObject('dataentity.logic.IPSDELogic') as IPSDELogic;
    if (ipsdelogic != null) {
      this.dstpsdelogicparam = ipsdelogic.findPSDELogicParam(value);
    }
    return this.dstpsdelogicparam;
  }

  get dstPSDELogicParam(): IPSDELogicParam | null {
    return this.getDstPSDELogicParam();
  }

  getDstPSDELogicParamMust(): IPSDELogicParam {
    const value = this.getDstPSDELogicParam();
    if (value == null) {
      throw new Error('未指定目标逻辑参数对象');
    }
    return value;
  }

  get srcFieldName(): string {
    return this.M.srcFieldName;
  }

  protected srcpsdelogicparam: IPSDELogicParam | null = null;

  getSrcPSDELogicParam(): IPSDELogicParam | null {
    if (this.srcpsdelogicparam != null) return this.srcpsdelogicparam;
    const value = this.M.getSrcPSDELogicParam;
    if (value == null) {
      return null;
    }
    const ipsdelogic = this.getParentPSModelObject('dataentity.logic.IPSDELogic') as IPSDELogic;
    if (ipsdelogic != null) {
      this.srcpsdelogicparam = ipsdelogic.findPSDELogicParam(value);
    }
    return this.srcpsdelogicparam;
  }

  get srcPSDELogicParam(): IPSDELogicParam | null {
    return this.getSrcPSDELogicParam();
  }

  getSrcPSDELogicParamMust(): IPSDELogicParam {
    const value = this.getSrcPSDELogicParam();
    if (value == null) {
      throw new Error('未指定源逻辑参数对象');
    }
    return value;
  }

  get cls(): string {
    return 'PSDEBindParamLogicImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.logic.IPSDEBindParamLogic') return true;
    return super.instanceof(cls);
  }
}
